(ns zesql.samples
  (:require [zesql.core :as zs :refer [defqueries]]))

(set! *warn-on-reflection* true)

(zs/debug-on!)
;(zs/debug-off!)

(def db-spec
  {:classname   "org.h2.Driver"
   :subprotocol "h2"
   :subname     "./zesql"
   :make-pool?  true
   :naming      {:keys   clojure.string/lower-case
                 :fields clojure.string/upper-case}})

(def delay-spec (delay
                  (println "delay spec")
                  db-spec))


(defqueries "zesql/query.sql" {:connection delay-spec})
(println "-------------")

(comment
  )
(println (testsql))
(println (test-const-order))
(println (test-const-order-dir))
(println (test-dynamic-order {:field "NAME"}))
(println (test-dynamic-order-dir {:field :name :dir "DESC"}))

;(repl/doc test-where)
(println (test-where))
(println (test-where {:id 2 :name "bbb"}))
(println (test-where {:id 2}))
(println (test-where {:name "aaa"}))

(println (test-set! {:id 3 :name "abc"}))

(println (test-new-order {:order [:id [:name :desc] :age]}))